package cn;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class BookDispatchServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String mybname=req.getParameter("bookname");
        List<Booker> userList=new ArrayList<>();
        try{
            DatabaseConnection databaseConnection=new DatabaseConnection();
            IUserDAO iUserDAO=new UserDAOImpl(databaseConnection.getConnection());
            userList=iUserDAO.findSomeBooks(mybname);

        } catch(Exception e){
            e.printStackTrace();
        }
        System.out.println("查询到的记录数="+userList.size());
        RequestDispatcher rd;
        req.setAttribute("bookSomeUsers",userList);
        rd=req.getRequestDispatcher("/Login/SuccessBook.jsp");
        rd.forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
